/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.view;

import com.model.Member;
import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Satellite
 */
public class TableModel extends AbstractTableModel {

    private List<Member> kategoris = new ArrayList<Member>();

    public TableModel(List<Member> kategoris) {
        this.kategoris = kategoris;
    }

    public int getRowCount() {
        return kategoris.size();
    }

    public int getColumnCount() {
        return 4;
    }

    public Object getValueAt(int rowIndex, int columnIndex) {
        Member b = kategoris.get(rowIndex);
        switch (columnIndex) {
            case 0:
                return b.getId();
            case 1:
                return b.getNama();
            case 2:
                return b.getAlamat();
            case 3:
                return b.getNo_telp();
            default:
                return "";
        }
    }

    @Override
    public String getColumnName(int column){
        switch (column) {
            case 0:
                return "ID";
            case 1:
                return "Nama";
            case 2:
                return "Alamat";
            case 3:
                return "No Telp";
            default:
                return "";
        }
    }
}
